package com.example.goods_manage.controller;

import com.example.goods_manage.dto.User;
import com.example.goods_manage.service.UserService;
import com.example.goods_manage.utils.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * <P> @Author: SongKeCheng
 * <P> Type: Class
 * <P> Description:
 * <P> Date: 2024/12/20:10:02
 */

@SuppressWarnings({"unchecked", ""})
@RestController
@RequestMapping("/user")
public class UserController {
    private static final Logger log = LoggerFactory.getLogger(UserController.class);


    @Autowired
    private UserService userService;

    /**
     * 登录接口
    */
    @PostMapping("/login")
    public AjaxResult login(@RequestBody User user){
        AjaxResult login = userService.login(user);
        return login;
    }

    @GetMapping("/info")
    public AjaxResult getInfo(User user){
        //  'admin-token': {
        //    roles: ['admin'],
        //    introduction: 'I am a super administrator',
        //    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
        //    name: 'Super Admin'
        //  },
        Map<String, Object> map = new HashMap<>();
        map.put("roles", Arrays.asList("admin"));
        map.put("introduction", "I am a super administrator");
        map.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        map.put("name", "Super Admin");
        return AjaxResult.success(map);
    }


}
